package wviz;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import javax.swing.SwingUtilities;

import prefuse.util.ui.JPrefuseApplet;
import wviz.gui.T2vPanel;

public class T2vPrefuseApplet extends JPrefuseApplet {
	
	public T2vPanel t2vPanel ;
	// Called when this applet is loaded into the browser.
	public void init() {
		// Execute a job on the event-dispatching thread; creating this applet's
		// GUI.		
		try {
			SwingUtilities.invokeAndWait(new Runnable() {
				public void run() {
					createGUI();	//	/			
				}
			});
		} catch (Exception e) {
			System.err.println("createGUI didn't complete successfully " + e);
		}
	}	
	
	public void getTextFromJavaScript(String fileName, String text){
	
		InputStream is = new ByteArrayInputStream( text.getBytes( ) );
		t2vPanel.visualiseStream(fileName, is);				
	}

	private void createGUI() {

		t2vPanel = new T2vPanel();
		// newContentPane.setOpaque(true);
		setContentPane(t2vPanel);
	}
}